@import (reference) 'mixins';

.box {
  .fluid-prop-sm(padding-left, @grid-left-sm, @grid-left-xl);
  .fluid-prop-sm(padding-right, @grid-right-sm, @grid-right-xl);

  &__row {
    .fluid-prop-sm(margin-left, @grid-left-sm, @grid-left-xl);
    .fluid-prop-sm(margin-right, @grid-right-sm, @grid-right-xl);

    display: flex;
    flex-wrap: wrap;
  }

  &__col {
    .fluid-prop-sm(padding-left, @grid-left-sm, @grid-left-xl);
    .fluid-prop-sm(padding-right, @grid-right-sm, @grid-right-xl);

    .col-make(xs, @xs-min);
    .col-make(sm, @sm-min);
    .col-make(xl, @xl-min);

    flex-basis: 0;
    flex-grow: 1;
    max-width: 100%;
    position: relative;
    transition: flex-basis @animation, max-width @animation;
  }
}

.col-make(@class, @query) {
  .col-loop(@grid-columns, @class, @query);

  &_@{class}_auto {
    @media @query {
      flex-basis: auto;
      max-width: none;
    }
  }
}

.col-loop(@index, @class, @query) when (@index >= 0) {
  .col-loop((@index - 1), @class, @query);

  &_@{class}_@{index} {
    @media @query {
      flex-basis: percentage((@index / @grid-columns));
      max-width: percentage((@index / @grid-columns));
    }
  }
}
